﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline.Processors;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
using BlackStar;

namespace BlackStarPipes
{
    [ContentTypeWriter]
    public class ThemePartContentWriter : ContentTypeWriter<ThemePart>
    {
        protected override void Write(ContentWriter output, ThemePart value)
        {
            WriteThemePart(output, value);
        }

        public override string GetRuntimeReader(TargetPlatform targetPlatform)
        {
            return typeof(ThemePartContentReader).AssemblyQualifiedName;
        }

        internal static void WriteThemePart(ContentWriter output, ThemePart value)
        {
            output.Write(value.AssetName);
            output.WriteObject<Dictionary<string, Rectangle>>(value.Rectangles);
            output.WriteObject<Dictionary<string, List<String>>>(value.PartLists);
            output.WriteObject<Point>(value.MinimumSize);
        }
    }

    [ContentTypeWriter]
    public class ThemeContentWriter : ContentTypeWriter<Theme>
    {
        protected override void Write(ContentWriter output, Theme value)
        {
            WriteTheme(output, value);
        }

        public override string GetRuntimeReader(TargetPlatform targetPlatform)
        {
            return typeof(ThemeContentReader).AssemblyQualifiedName;
        }

        internal static void WriteTheme(ContentWriter output, Theme value)
        {
            output.WriteObject<Dictionary<string, Cursor>>(value.Cursors);
            output.WriteObject<Dictionary<String, Font>>(value.Fonts);
            output.WriteObject<ThemePart>(value.Form);
            output.WriteObject<ThemePart>(value.Button);
            output.WriteObject<ThemePart>(value.Textbox);
        }
    }

}
